home *** CD-ROM | disk | FTP | other *** search
- # Jedi Knight Cog Script
- #
- # WEAP_STRIFLE.COG
- #
- # WEAPON 3 script - Stormtrooper Rifle
- #
- # The standard rifle used by the stormtroopers. Not as accurate as the Bryar Pistol.
- # This weapon has only one type of fire.
- #
- # - Affected by MagSealed sectors/surfaces.
- #
- # [YB & CYW]
- #
- # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
-
-
- symbols
-
- model povModel=strv.3do local
- model povModel_m=strv_m.3do local
- model weaponMesh=strg.3do local
-
- keyframe mountAnim=StrVmnt.key local
- keyframe dismountAnim=StrVdis.key local
- keyframe povfireAnim=StrVpst1.key local
- keyframe holsterAnim=kyhlstr.key local
-
- sound mountSound=df_rif_ready.wav local
- sound dismountSound=PutWeaponAway01.wav local
- sound fireSound=trprsht2.wav local
- sound outSound=trprout.wav local
- sound failSound=weapfail.wav local
-
- template projectile=+stlaser local
- template projectileB=+swsparks local
-
- thing player local
-
- vector randVec local
-
- flex fireWait=0.2 local
- flex holsterWait local
- flex powerBoost local
- flex autoAimFOV=25 local
- flex autoAimMaxDist=5 local
-
- int dummy local
- int trackID=-1 local
- int fireChannel=-1 local
- int holsterTrack local
- int mode local
-
- message activated
- message deactivated
- message selected
- message deselected
- message autoselect
- message fire
- message timer
-
- end
-
- # ========================================================================================
-
- code
-
- fire:
- player = GetSourceRef();
- mode = GetSenderRef();
-
- // Check that the player is still alive.
- if(GetThingHealth(player) <= 0)
- {
- Return;
- }
-
- // Check Ammo - If we are out, autoselect best weapon.
- // It should always use two energy cells, but -- as in DF --
- // allow the last fire if there is only one left...
- if(GetInv(player, 11) < 1.0)
- {
- PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
- if((GetAutoSwitch() & 1))
- SelectWeapon(player, GetWeaponBin(AutoSelectWeapon(player, 1)));
- Return;
- }
-
- // Get random aiming error
- randVec = VectorSet((Rand()-0.5)*5, (Rand()-0.5)*5, 0.0);
-
- SendMessageEx(GetThingClassCog(GetLocalPlayerThing()), user1, 3, 0, 0, 0);
-
- SetPOVShake('0.0 -.003 0.0', '1.5 0.0 0.0', .05, 80.0);
- if (GetInv(player, 93) > 0.0)
- dummy = FireProjectile(player, projectileB, failSound, 8, '0.0168 0.1896 0.00', randVec, 1.0, 0x30, autoAimFOV, autoAimFOV*2);
- else
- dummy = FireProjectile(player, projectile, fireSound, 8, '0.0168 0.1896 0.00', randVec, 1.0, 0x30, autoAimFOV, autoAimFOV*2);
- // SetThingVel(dummy, vectorScale(GetThingVel(dummy), 0.01));
-
- ChangeInv( player, 11, -2.0 );
- jkPlayPOVKey( player, povfireAnim, 1, 0x38 );
-
- powerBoost = GetInv(player, 63);
- ChangeFireRate(player, fireWait/powerBoost);
-
- Return;
-
- # ........................................................................................
-
- activated:
- player = GetSourceRef();
- mode = GetSenderRef();
-
- if (GetInv(player, 93) > 0.0)
- SendMessageEx(GetThingClassCog(player), skill, 1100, 0, 0, 0);
-
- jkSetWaggle(player, '0.0 0.0 0.0', 0);
- powerBoost = GetInv(player, 63);
- ActivateWeapon(player, fireWait/powerBoost, mode);
- Return;
-
- # ........................................................................................
-
- deactivated:
- player = GetSourceRef();
- jkSetWaggle(player, '10.0 7.0 0.0', 350);
- DeactivateWeapon(player, mode);
- Return;
-
- # ........................................................................................
-
- selected:
- player = GetSourceRef();
-
- PlayMode(player, 41);
- PlaySoundThing(mountSound, player, 1.0, -1, -1, 0x80);
- if (GetInv(player, 67) == 0.0)
- jkSetPOVModel(player, povModel); // Kyle hand
- else
- jkSetPOVModel(player, povModel_m); // Mara Hand
- SetArmedMode(player, 1);
- jkSetWeaponMesh(player, weaponMesh);
- jkSetWaggle(player, '10.0 7.0 0.0', 350);
- trackID = jkPlayPOVKey(player, mountAnim, 0, 20);
- SetMountWait(player, GetKeyLen(mountAnim));
- jkClearFlags(player, 0x5);
- SetCurWeapon(player, GetWeaponBin(3));
-
- SetTimerEx(1.0, 10, 0.0, 0.0);
-
- Return;
-
- # ........................................................................................
-
- deselected:
- player = GetSourceRef();
-
- PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
- jkPlayPOVKey(player, dismountAnim, 0, 18);
- holsterWait = GetKeyLen(holsterAnim);
- SetMountWait(player, holsterWait);
- holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
- SetTimerEx(holsterWait, 2, 0.0, 0.0);
- if (trackID != -1)
- {
- jkStopPOVKey(player, trackID, 0);
- trackID = -1;
- }
- jkSetWaggle(player, '0.0 0.0 0.0', 0);
-
- Return;
-
- # ........................................................................................
-
- autoselect:
- player = GetSourceRef();
-
- // If the player has the weapon
- if(GetInv(player, GetWeaponBin(3)) != 0.0)
- {
- // If the player has ammo or has the scope up.
- if (
- GetInv(player, 11) != 0.0 ||
- GetCurWeapon(player) == 13
- )
- {
- ReturnEx(600.0);
- }
- else
- {
- ReturnEx(-1.0);
- }
- }
- else
- {
- ReturnEx(-1.0);
- }
-
- Return;
-
- # ........................................................................................
-
- timer:
- if (GetSenderID() == 2)
- StopKey(player, holsterTrack, 0.0);
- else
- if (GetSenderID() == 10)
- if (GetCurWeapon(player) == 3)
- SetCameraZoom(0, 1.0, 500.0);
-
- Return;
-
- end
-
-